function fig = bin2fig(bin)
  % Converts an int8 (binary) array into a Matlab figure
  
    global procLogStr flightLogStr castLogStr
    
    fig = [];
    
    name = char(randi(26,1,8)+64); % generate a random name, just in case
                                   % temp, tmp, etc., already exist in wd

  % fopen a file in binary write mode
    [b, msg] = fopen([name '.fig'], 'w');
    if b==-1
        procLogStr{end+1} = ['bin2fig error: ' msg '.  '];
        return
    end

  % fwrite as int8
    fwrite(b, bin, 'int8');
    
  % Close the file
    fail = fclose(b);
    if fail
        procLogStr{end+1} = ['bin2fig error: fclose returned error code '...
                         num2str(fail) '.  '];
        fclose('all');
    end

  % Load the figure & clean up
    try
        fig = hgload([name '.fig']);
        dos(['del ' name '.fig']);
    catch ME
        procLogStr{end+1} = ['bin2fig error: ' getReport(ME) '.  '];
        return
    end

end